package com.intel.factorytest.cfparser;

import android.content.Context;

import com.intel.factorytest.cfparser.concrete.AConfigFileParser;
import com.intel.factorytest.cfparser.factory.ConfParserFactory;
import com.intel.factorytest.cfparser.factory.NoneExtensionConfParserFactory;
import com.intel.factorytest.cfparser.factory.PropertiesConfParserFactory;
import com.intel.factorytest.cfparser.factory.XmlConfParserFactory;

public class ConfigFileParseUtil {
    
    public static AConfigFileParser getConfParserConcrete(Context context, String extension) {
        
        if (context == null || extension == null) return null;
        
        ConfParserFactory factory = null;
        AConfigFileParser parser = null;
        if (extension.equals(AConfigFileParser.EXTENSION_NONE)) {
            factory = new NoneExtensionConfParserFactory();
            parser = factory.factory(context);
        } else if (extension.equals(AConfigFileParser.EXTENSION_PROPERTISE)) {
            factory = new PropertiesConfParserFactory();
            parser = factory.factory(context);
        } else if (extension.equals(AConfigFileParser.EXTENSION_XML)) {
            factory = new XmlConfParserFactory();
            parser = factory.factory(context);
        } else {
            // error handling
        }
        
        return parser;
    }

}
